package cn.com.code.hwjs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDateTime;
import java.util.Locale;
import java.util.Scanner;

/**
 * 字符串通配符
 * https://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036?tpId=37&tqId=21294&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/5/24
 */
public class Hwjs71 {

  public static void main(String[] args) throws IOException {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String value;
    while ((value = bf.readLine()) != null) {
      String target = bf.readLine();
      value = value.toLowerCase(Locale.ROOT);
      target = target.toLowerCase(Locale.ROOT);
      String regx = value.replaceAll("\\*{2,}","\\*");
      regx = regx.replaceAll("\\?","[0-9a-z]{1}");
      regx = regx.replaceAll("\\*","[0-9a-z]{0,}");
      System.out.println(target.matches(regx));
    }
  }

}
